﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <!--作为公共模版分离出去-->
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="admin/images/rookieCs.ico" />
    <link rel="Shortcut Icon" href="admin/images/rookieCs.ico" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui/css/H-ui.my.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/css/h-ui.admin.pro.iframe.min.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/Hui-iconfont/1.0.9/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/lc_switch/20160127/css/lc_switch.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/mywork.css" />
    <script type="text/javascript" src="admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="admin/lib/layer/3.1.1/layer.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/plugins/datagrid-detailview.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="admin/lib/lc_switch/20160127/js/lc_switch.min.js"></script>
    <script>document.write('<script type="text/javascript" src="admin/js/common.js?v='+ Date.now() +'"><\/script>');</script>
    <script>document.write('<script type="text/javascript" src="admin/js/formatter.js?v='+ Date.now() +'"><\/script>');</script>
    <!--作为公共模版分离出去-->
    <title>我的业绩条目</title>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif" memuId="salary-entry-list">
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en" style="float: none">&gt;</span> 业绩管理
    <span class="c-gray en" style="float: none">&gt;</span> 我的业绩条目
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div data-options="region:'center', border:false">
    <!--按钮元素-->
    <div id="buttonInfo" style="padding: 2px 0px 2px 5px; background-color: #F5FAFE;">
        <button class="easyui-linkbutton" onclick="query(pageParam, true)"><i class="Hui-iconfont">&#xe665;</i>查询</button>
    </div>
    <!--表格元素-->
    <div id="tableInfo"></div>
</div>
<div data-options="region:'east', title:'查询条件', hideCollapsedContent:false, collapsible:true, collapsed:true" style="width:250px">
    <!--查询条件元素-->
    <form id="searchFormInfo" style="display: none">
        <div class="searchLabel">所属员工：<input id="s_belongUserId" name="belongUserId"/></div>
        <div class="searchLabel">客户品牌：<input id="s_customerBrand" name="customerBrand"/></div>
        <div class="searchLabel">媒体名称：<input id="s_mediumName" name="mediumName"/></div>
        <div class="searchLabel">归属月份：<input id="s_belongMonth" name="belongMonth"/></div>
        <div class="searchLabel">公司主体：<input id="s_type" name="type"/></div>
    </form>
</div>
<script type="text/javascript">
    var roleType = sessionStorage.getItem("roleType");
    var isSup = sessionStorage.getItem("isSup");
    //准备函数
    $(function () {
        initSearchForm();
        initGrid();
        getGridHidden("tableInfo");
        query(pageParam);
    });

    //查询条件初始化
    function initSearchForm() {
        $("#s_belongUserId").combobox({
            width: 160,
            panelHeight: "auto",
            valueField: "id",
            textField: "name",
            editable: true,
            url: roleType === "GLB" || roleType === "CWB" ? "user/listUserByRoleCode?roleCode=ALL" : "user/listSubUser?hasSelf=true",
            method: "GET",
            loadFilter: function (data) {
                var temp = data.bizData;
                if (temp.length > 1) {
                    temp.unshift({"id": "ALL", "name": "全部"});
                }
                return temp;
            }
        });
        $("#s_customerBrand").textbox({
            width: 160
        });
        $("#s_mediumName").textbox({
            width: 160
        });
        $("#s_belongMonth").datebox({
            width: 160,
            editable: false,
            onShowPanel: function () {
                //触发click事件弹出月份层
                span.trigger('click');
                if (!tds)
                //延时触发获取月份对象，因为上面的事件触发和对象生成有时间间隔
                    setTimeout(function() {
                        tds = p.find('div.calendar-menu-month-inner td');
                        tds.click(function(e) {
                            //禁止冒泡执行easyui给月份绑定的事件
                            e.stopPropagation();
                            //得到年份
                            var year = /\d{4}/.exec(span.html())[0] ,
                                //月份
                                //之前是这样的month = parseInt($(this).attr('abbr'), 10) + 1;
                                month = parseInt($(this).attr('abbr'), 10);

                            //隐藏日期对象
                            $("#s_belong_month").datebox('hidePanel')
                            //设置日期的值
                                .datebox('setValue', year + '-' + month);
                        });
                    }, 0);
            },
            //配置parser，返回选择的日期
            parser: function (s) {
                if (!s) return new Date();
                var arr = s.split('-');
                return new Date(parseInt(arr[0], 10), parseInt(arr[1], 10) - 1, 1);
            },
            //配置formatter，只返回年月 之前是这样的d.getFullYear() + '-' +(d.getMonth());
            formatter: function (d) {
                var currentMonth = (d.getMonth()+1);
                var currentMonthStr = currentMonth < 10 ? ('0' + currentMonth) : (currentMonth + '');
                return d.getFullYear() + '-' + currentMonthStr;
            }
        });
        //日期选择对象
        var p = $('#s_belongMonth').datebox('panel'),
            //日期选择对象中月份
            tds = false,
            //显示月份层的触发控件
            span = p.find('span.calendar-text');
        $("#s_type").combobox({
            width: 160,
            panelHeight: "auto",
            valueField: "value",
            textField: "text",
            data: [{value:1, text:"媒体"}, {value:2, text:"排期"}]
        });
        $("#searchFormInfo").show();
    }

    //表格元素初始化
    function initGrid() {
        $("#tableInfo").datagrid({
            pagination: true,
            singleSelect: true,
            fitColumns: true,
            striped: true,
            fit: true,
            columns: [[
                {field: "id", title: "编号", width: 60, align: "center", sortable: true},
                {field: "orderId", title: "排期编号", width: 100, align: "center", sortable: true},
                {field: "customerBrand", title: "客户品牌", width: 150, align: "center", sortable: true},
                {field: "mediumName", title: "媒体名称", width: 150, align: "center", sortable: true},
                {field: "mediumType", title: "媒体类型", width: 80, align: "center", sortable: true, formatter: mediumTypeFormatter},
                {field: "type", title: "类型", width: 80, align: "center", sortable: true,
                    formatter: function (value) {
                        return value === 1 ? "媒体" : "排期";
                    }
                },
                {field: "money", title: "金额", width: 120, align: "center", sortable: true},
                {field: "belongUserName", title: "归属员工", width: 100, align: "center", sortable: true},
                {field: "belongMonth", title: "归属月份", width: 100, align: "center", sortable: true},
                {field: "createDate", title: "创建日期", width: 140, align: "center", sortable: true, formatter: dateTimeFormatter}
            ]],
            toolbar: ".breadcrumb, #buttonInfo, #searchInfo",
            pageNumber: pageParam.pageNo,
            pageSize: pageParam.pageSize,
            pageList: Page.getPageList(),
            onSortColumn: function (orderBy, sortBy) {
                pageParam.pageNo = 1;
                pageParam.orderBy = orderBy;
                pageParam.sortBy = sortBy;
                query(pageParam);
            },
            onSelect: function() {
                selectedTableRow();
            },
            onUnselect: function() {
                selectedTableRow();
            },
            onSelectAll: function() {
                selectedTableRow();
            },
            onUnselectAll: function() {
                selectedTableRow();
            },
            onLoadSuccess: function() {
                toolBarBtnDisabledById([false], "buttonInfo");
            }
        }).datagrid("getPager").pagination({
            buttons: [
                {text: "个性化设置", iconCls: "icon-tip", handler: function() {selectColumnMenu("tableInfo");}},
                {text: "&emsp;<span id='sumQuotedPrice'></span>&emsp;<span id='sumCostPrice'></span>&emsp;<span id='sumProfit'></span>&emsp;<span id='sumProfitRate'></span>"}
            ],
            onSelectPage: function(pageNumber, pageSize) {
                pageParam.pageNo = pageNumber;
                pageParam.pageSize = pageSize;
                query(pageParam);
            },
            onChangePageSize: function(pageSize) {
                pageParam.pageSize = pageSize;
            }
        });
        //表格事件
        var selectedTableRow = function() {
            var selectRow = $("#tableInfo").datagrid("getSelections");
            if (selectRow.length === 0) {
                toolBarBtnDisabledById([false], "buttonInfo");
            } else if (selectRow.length === 1) {
                toolBarBtnDisabledById([false], "buttonInfo");
            } else {
                toolBarBtnDisabledById([false], "buttonInfo");
            }
        };
    }

    //分页查询
    function query(pageParam, goHead) {
        pageParam.condition = getFormJson($("#searchFormInfo"));
        if (goHead && goHead)
            pageParam.pageNo = 1;
        ajaxGetFun("salary/querySalaryEntryPage", pageParam, function(bizData) {
            $("#tableInfo").datagrid("loadData", bizData.rowList);
            $("#tableInfo").datagrid("getPager").pagination({pageNumber: bizData.pageNo, total: bizData.total});
        }, null, "获取业绩条目列表");
    }
</script>
</body>
</html>